// 当前这个模块：API进行统一管理
import requests from "./request";

import mockRequests from './mockAjax'

//三级联动接口
///api/product/getBaseCategoryList get
// 无参数
//发请求：axios发请求返回结果Promise对象
export const reqCategoryList = () => {
    let result = requests({ url: '/product/getBaseCategoryList', method: 'get' })
    console.log(result)
    return result
}

// 获取banner（Home首页轮播图接口）
export const reqGetBannerList = () => mockRequests.get('/banner')

export const reqFloorList = () => mockRequests.get('/floor')

export const reqGetSearchInfo = (params) => requests({ url: "/list", method: "post", data: params })

export const reqGoodsInfo = (skuId) => {
    let result = requests({ url: `/item/${skuId}`, method: 'get' })
    return result
}

export const reqAddOrUpdateShopCart = (skuId, skuNum) => {
    let result = requests({ url: `/cart/addToCart/${skuId}/${skuNum}`, method: 'post' })
    return result
}

export const reqCartList = () => {
    let result = requests({ url: '/cart/cartList', method: 'get' })
    console.log(result)
    return result
}

export const reqDeleteCartById = (skuId) => requests({ url: `/cart/deleteCart/${skuId}`, method: 'delete' })

export const reqUpdateCheckedByid = (skuId, isChecked) => requests({ url: `/cart/checkCart/${skuId}/${isChecked}`, method: 'get' })

export const reqUserRegister = (data) => requests({ url: '/user/passport/register', data, method: 'post' })

export const reqGetCode = (phone) => {
    let result = requests({ url: `/user/passport/sendCode/${phone}`, method: 'get' })
    console.log(result)
    return result
}

export const reqUserLogin = (data) => {
    let result = requests({ url: '/user/passport/login', data, method: 'post' })
    console.log(result)
    return result
}

export const reqUserInfo = () => requests({ url: '/user/passport/auth/getUserInfo', method: 'get' })

export const reqLogout = () => requests({ url: '/user/passport/logout', method: 'get' })

export const reqAddressInfo = () => requests({ url: '/user/userAddress/auth/findUserAddressList', method: 'get' })

export const reqOrderInfo = () => requests({ url: '/order/auth/trade', method: 'get' })

export const reqSubmitOrder = (tradeNo, data) => {
    
    let result = requests({ url: `/order/auth/submitOrder?tradeNo=${tradeNo}`, data, method: 'post' })
    console.log(result)
    return result
}

export const reqPayInfo = (orderId) => requests({ url: `/payment/weixin/createNative/${orderId}`, method: 'get' })

export const reqMyOrderList = (page, limit) => requests({ url: `/order/auth/${page}/${limit}`, method: 'get' })